﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CRUD;

namespace Client
{
    public partial class PersonF : Form
    {
        public Person curper=null;
        public IPresenter ip = null;
        public Form firstF = null;
        public PersonF()
        {
            InitializeComponent();
        }       
        public void ShowThis() 
        {
            if (curper != null) 
            {
                ID_b.Text = curper.id.ToString();
                Age_B.Text = curper.Age.ToString();
                Lname_B.Text = curper.LName;
                Fname_B.Text = curper.FName;
            }
            Show();
        }
        private void update_btn_Click(object sender, EventArgs e)
        {
            if (curper != null)
            {
                ip.update(Convert.ToInt32(ID_b.Text), Lname_B.Text, Fname_B.Text, Convert.ToInt32(Age_B.Text));
            }
            else 
            {
                ip.create(Convert.ToInt32(ID_b.Text), Lname_B.Text, Fname_B.Text, Convert.ToInt32(Age_B.Text));

            }
        }
        private void cancel_btn_Click(object sender, EventArgs e)
        {
            firstF.Show();
            Hide();
        }

        private void delete_btn_Click(object sender, EventArgs e)
        {
            ip.delete(Convert.ToInt32(ID_b));
            firstF.Show();
            Hide();
        }
    }
}
